function Table1

addpath('../Data')
addpath('basic_functions')

% defines the cut of long-short portfolios
UB = 90;
LB = 10;

[Return,Z,IsF,Nt,Chars,CharsNames,time_beg,~,~] = package_data_all_greeks;

% define returns (mid-price, long and short with TC) 
ret = Return.ret_daily;
ret_long = Return.ret_long_60_daily;
ret_short = Return.ret_short_60_daily;

[N,T,L] = size(Chars);
XXX = Z;

% compute unconditional mean of sorts to define direction
RET = NaN(T,L);
mean_ret = NaN(L,1);
for i = 1:L
    for t = 2:T
        ind = ~isnan(ret(:,t)) & ~isnan(XXX(:,t-1,i));
        if sum(ind) > 0
            xx = XXX(~~ind,t-1,i);
            n1 = xx<=prctile(unique(xx),LB);
            n2 = xx>=prctile(unique(xx),UB);

            rr = ret(~~ind,t);
            RET(t,i) = mean(rr(n2),'omitnan') - mean(rr(n1),'omitnan');
        end
    end
    mean_ret(i) = mean(RET(:,i),'omitnan');
end

RET = NaN(T,L,2);
strat_ret = NaN(L,4);
for i = 1:L
    for t = 2:T
        ind = ~isnan(ret(:,t)) & ~isnan(XXX(:,t-1,i));
        if sum(ind) > 0
            xx = XXX(~~ind,t-1,i);
            % compute sort so that average return is always positive
            if mean_ret(i,1) > 0
                nS = xx<=prctile(unique(xx),LB);
                nL = xx>=prctile(unique(xx),UB);
            else
                nS = xx>=prctile(unique(xx),UB);
                nL = xx<=prctile(unique(xx),LB);
            end
            rr = ret(~~ind,t);
            RET(t,i,1) = mean(rr(nL),'omitnan') - mean(rr(nS),'omitnan');

            rrL = ret_long(~~ind,t);
            rrS = ret_short(~~ind,t);
            RET(t,i,2) = mean(rrL(nL),'omitnan') - mean(rrS(nS),'omitnan');
        end
    end

    for j = 1:size(RET,3)
        ind = isfinite(RET(:,i,j));
        strat_ret(i,2*j-1) = mean(RET(~~ind,i,j),'omitnan');
        strat_ret(i,2*j) = sqrt(sum(ind))*mean(RET(~~ind,i,j),'omitnan')./std(RET(~~ind,i,j),'omitnan');
    end
end

% compute BH bounds
YY = strat_ret;
bh_t(1:2) = BH(tstat2pval(YY(:,2)).*(YY(:,2)>0) + (1-tstat2pval(YY(:,2))).*(YY(:,2)<=0),0.05);
bh_t(3:4) = BH(tstat2pval(YY(:,4)).*(YY(:,4)>0) + (1-tstat2pval(YY(:,4))).*(YY(:,4)<=0),0.05);

for i = 1:size(YY,1)
    bb = [];
    for j = 1:size(YY,2)
        if ~isnan(YY(i,j))
            if mod(j,2) == 1
                if floor(100*YY(i,j+1)) >= floor(100*bh_t(j))
                    bb = [bb '&\textbf{' num2str_math(100*YY(i,j),'%1.2f') '}'];
                else
                    bb = [bb '&' num2str_math(100*YY(i,j),'%1.2f')];
                end
            else
                if floor(100*YY(i,j)) >= floor(100*bh_t(j))
                    bb = [bb '&\textbf{(' num2str_math(YY(i,j),'%1.2f') ')}'];
                else
                    bb = [bb '&(' num2str_math(YY(i,j),'%1.2f') ')'];
                end
            end
            if j == 2
                bb = [bb '&'];
            end
        else
            bb = [bb '&--'];
        end
    end
    if mean_ret(i,1)>0
        disp([CharsNames{i,1} '&10$-$1&'  bb '\\'])
    else
        disp([CharsNames{i,1} '&1$-$10&'  bb '\\'])
    end
end

return